Product Code Database
Example Keywords: nintendo -belt $21
   » » Wiki: Logic Error
Tag Wiki 'Logic Error'.
Tag

Logic error
 (

 C O N T E N T S 
Rank: 100%
Bluestar Bluestar Bluestar Bluestar Blackstar

In computer programming, a logic error is a or in a program that causes it to operate incorrectly, but not to terminate abnormally (or crash).

(2010). 9781449612832, Jones & Bartlett Publishers. .
A logic error produces unintended or undesired output or other behaviour, although it may not immediately be recognized as such.

Logic errors occur in both and interpreted languages. Unlike a program with a , a program with a logic error is a valid program in the language, though it does not behave as intended. Often the only clue to the existence of logic errors is the production of wrong solutions, though static analysis may sometimes spot them.


Debugging logic errors
One of the ways to find this type of error is to put out the program's variables to a file or on the screen in order to determine the error's location in code. Although this will not work in all cases, for example when calling the wrong , it is the easiest way to find the problem if the program uses the incorrect results of a bad .


Examples
This example function in C to calculate the of two numbers contains a logic error. It is missing parentheses in the calculation, so it compiles and runs but does not give the expected answer due to operator precedence (division is evaluated before addition). float average(float a, float b) {
   return a + b / 2;  // should be (a + b) / 2
     
}


See also

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs